package com.example.siyun.service.impl.courseserviceimpl;

import com.example.siyun.mapper.coursemapper.TreeMapper;
import com.example.siyun.pojo.CourseTree;
import com.example.siyun.service.courseservice.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description:教师模块课程列表树形组件
 */
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private TreeMapper treemapper;
    /**
     * 获取课程左侧树形结构
     * @ruturn 返回查询出来的树形数据
     */
    @Transactional
    @Override
    public List<CourseTree> findTree() {
        return treemapper.findTree();
    }
    /**
     * 通过id删除的对应的树形信息
     * @param id 要查询微圈的id
     */
    @Transactional
    @Override
    public void del(int id) {
        treemapper.delTree(id);
    }
    /**
     * 添加树形信息
     * @param coursetree 要添加的信息
     */
    @Transactional
    @Override
    public void addTree(CourseTree coursetree) {
        treemapper.addTree(coursetree);
    }
    /**
     * 修改树形信息
     * @param coursetree 要修改的信息
     */
    @Transactional
    @Override
    public void editTree(CourseTree coursetree) {
        treemapper.editTree(coursetree);
    }
    /**
     * 删除子节点数据
     * @param id 要删除的要删除节点的id
     */
    @Transactional
    @Override
    public void delTreeZi(int id) {
        treemapper.delTreeZi(id);
    }
    /**
     * 删除子节点的所有数据
     * @param id 要删除的要删除节点的id
     */
    @Override
    @Transactional
    public void delAll(int id) {
        treemapper.delTreeZi(id);
        treemapper.delTree(id);
    }

}
